package com.laf.manage.domain.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import com.laf.common.annotation.Excel;
import com.laf.common.core.domain.BaseEntity;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;

/**
 * 消息推送记录对象 tb_push_msg
 *
 * @author zian
 * @date 2024-10-30
 */
@Data
@ToString
@NoArgsConstructor
@Accessors(chain = true)
@TableName("tb_push_msg")
@ApiModel(value = "PushMsg", description = "消息推送记录实体")
public class PushMsg
{
    private static final long serialVersionUID = 1L;

    /** 主键 */
    @TableId(type= IdType.AUTO)
    @ApiModelProperty("主键")
    private Long id;

    /** 设备id */
    @Excel(name = "设备id")
    @ApiModelProperty("设备id")
    private String cId;

    /** 用户id */
    @Excel(name = "用户id")
    @ApiModelProperty("用户id")
    private Long userId;

    /** 设备平台 */
    @Excel(name = "设备平台")
    @ApiModelProperty("设备平台")
    private String clientPlatform;

    /** 用户昵称 */
    @Excel(name = "用户昵称")
    @ApiModelProperty("用户昵称")
    private String nickName;

    /** 标题 */
    @Excel(name = "标题")
    @ApiModelProperty("标题")
    private String title;

    /** 内容 */
    @Excel(name = "内容")
    @ApiModelProperty("内容")
    private String content;


    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

    /** 请求参数 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    @TableField(exist = false)
    private Map<String, Object> params;

    public LocalDateTime getBeginTime()
    {
        if (params!= null && params.get("beginTime")!=null ){
            return LocalDateTime.parse(params.get("beginTime").toString(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        }
        return null;
    }

    public LocalDateTime getEndTime()
    {
        if (params!= null && params.get("endTime")!=null ){
            return LocalDateTime.parse(params.get("endTime").toString(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        }
        return null;
    }

}
